﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;

using BusinessManagementStudio.ViewModel;
using BusinessManagementStudio.Utilities;

namespace BusinessManagementStudio.Controllers
{
    public class HomeController : Controller
    {
        //
        // GET: /User/

        public ActionResult Index()
        {
            return View();
        }

        [HttpGet]
        public ActionResult Successful(String ComName, String FMName, String ClientName, String ContractorName, String ComID, String QuoteNo)
        {
            CreationSuccessful createSucess = new CreationSuccessful();
            createSucess.IsContractorAssignment = false;
            createSucess.CompanyName = ComName;
            createSucess.IsCompany = false;
            if (createSucess.CompanyName != "" && createSucess.CompanyName != null)
                createSucess.IsCompany = true;

            createSucess.FMName = FMName;
            createSucess.IsFM = false;
            if (createSucess.FMName != "" && createSucess.FMName != null)
                createSucess.IsFM = true;

            createSucess.ClientName = ClientName;
            createSucess.IsClient = false;
            if (createSucess.ClientName != "" && createSucess.ClientName != null)
                createSucess.IsClient = true;

            createSucess.ContractorName = ContractorName;
            createSucess.IsContractor = false;
            if (createSucess.ContractorName != "" && createSucess.ContractorName != null
                && (ComID == "" || ComID == null) && (QuoteNo == "" || QuoteNo == null))
                createSucess.IsContractor = true;

            createSucess.ContractorAssignment = "";
            createSucess.IsContractorAssignment = false;
            if (ContractorName != "" && ContractorName != null
                && ComID != "" && ComID != null && QuoteNo != "" && QuoteNo != null)
                createSucess.IsContractorAssignment = true;

            if(createSucess.IsCompany == true)
                createSucess.CompanyName = ComName + " is created successfully (Company)!";
            
            if(createSucess.IsFM == true)
                createSucess.FMName = FMName + " is created successfully (FM)!";

            if (createSucess.IsClient == true)
                createSucess.ClientName = ClientName + " is created successfully (Client)!";

            if (createSucess.IsContractor == true)
                createSucess.ContractorName = ContractorName + " is created successfully (Contractor)!";

            if(createSucess.IsContractorAssignment == true)
                createSucess.ContractorAssignment = QuoteNo + " of Company " + ComID + " is assigned to " + ContractorName;

            return View(createSucess);
        }
    }
}
